import javax.swing.*;
import java.awt.*;

public class UserInterface extends JFrame
{

    private JTabbedPane tabbedPane;
    private final String[] searchComboBoxElements = {"Title", "Actor",
                    "Director","Year", "Genre", "Keywords"};

    private JButton search;
    private JButton history;
    private JButton btnDemandFactor;
    private JButton btnFrequentRenter;
    private JButton btn24Hour;
    private JButton btnAddMovie;
    private JButton manageUser;

    private String mship;

    private RAMActionListener actionListener;

    public UserInterface(int mship){

		this.mship = Integer.toString(mship);

        System.out.println("Starting GUI");
        actionListener = new RAMActionListener(this);


        tabbedPane = new JTabbedPane();
        JPanel userPanel = new JPanel();
        userPanel.setLayout(new BoxLayout(userPanel, BoxLayout.Y_AXIS));
        JLabel userPanelTitle = new JLabel("User Panel");
        userPanelTitle.setAlignmentX(Component.CENTER_ALIGNMENT);
        userPanel.add(userPanelTitle);

        search = new JButton("Search");
        search.setAlignmentX(Component.CENTER_ALIGNMENT);
        search.addActionListener(actionListener);
        search.setActionCommand("search");

        userPanel.add(search);
        userPanel.add(Box.createRigidArea(new Dimension(0,50)));

        history = new JButton("History");
        history.setAlignmentX(Component.CENTER_ALIGNMENT);
        history.addActionListener(actionListener);
        history.setActionCommand("clientHistory");
        userPanel.add(history);

        tabbedPane.addTab("User Interface", userPanel);


        JPanel adminPanel = new JPanel();
        adminPanel.setLayout(new BoxLayout(adminPanel, BoxLayout.Y_AXIS));
        JLabel adminPanelTitle = new JLabel("Admin Panel");
        adminPanel.add(adminPanelTitle);
        adminPanelTitle.setAlignmentX(Component.CENTER_ALIGNMENT);
        tabbedPane.addTab("Admin Interface", adminPanel);

        adminPanel.add(Box.createRigidArea(new Dimension(0,10)));
        btn24Hour = new JButton("24 Hour Activity");
        btn24Hour.setAlignmentX(Component.CENTER_ALIGNMENT);
        btn24Hour.addActionListener(actionListener);
        btn24Hour.setActionCommand("24");
        adminPanel.add(btn24Hour);

        adminPanel.add(Box.createRigidArea(new Dimension(0,10)));
        btnDemandFactor = new JButton("Demand Factor");
        btnDemandFactor.setAlignmentX(Component.CENTER_ALIGNMENT);
        btnDemandFactor.addActionListener(actionListener);
        btnDemandFactor.setActionCommand("df");
        adminPanel.add(btnDemandFactor);

        adminPanel.add(Box.createRigidArea(new Dimension(0,10)));
        btnFrequentRenter = new JButton("Frequent Renter");
        btnFrequentRenter.setAlignmentX(Component.CENTER_ALIGNMENT);
        btnFrequentRenter.addActionListener(actionListener);
        btnFrequentRenter.setActionCommand("freq");
        adminPanel.add(btnFrequentRenter);

        adminPanel.add(Box.createRigidArea(new Dimension(0,10)));
        btnAddMovie = new JButton("Add a Movie");
        btnAddMovie.setAlignmentX(Component.CENTER_ALIGNMENT);
        btnAddMovie.addActionListener(actionListener);
        btnAddMovie.setActionCommand("ADDMOVIE");
        adminPanel.add(btnAddMovie);

        adminPanel.add(Box.createRigidArea(new Dimension(0,10)));
        manageUser = new JButton("Manage Users");
        manageUser.setAlignmentX(Component.CENTER_ALIGNMENT);
        manageUser.addActionListener(actionListener);
        manageUser.setActionCommand("manageUsers");
        adminPanel.add(manageUser);

        Container cp;
        cp = getContentPane();
        cp.add(tabbedPane);

        Toolkit tk;
        Dimension d;
        tk = Toolkit.getDefaultToolkit();
        d = tk.getScreenSize();
        setSize(300, 400);
        setResizable(true);
        setLocation((d.width/2)-150, (d.height/2)-200);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setTitle("Rent A Movie");
        setVisible(true);

    }


    public String getMShip(){
        return mship;
    }


}
